package com.xinlu.util.tool;

import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

import com.xinlu.common.log.Logger;

public class EmailUtil {
	
	protected static  Logger log = Logger.getLogger(EmailUtil.class);
	
	public static void sendEmailMessage(String message, String toMessage) throws EmailException {
		
//		try{
			
			
			Email email = new SimpleEmail();
			email.setHostName("smtp.163.com");
			email.setAuthenticator(new DefaultAuthenticator("xddyl", "395152"));
			email.setTLS(true);
			email.setFrom("xddyl@163.com");
			email.setSubject("修改密码!");
			email.setMsg("你的动态密码是：" + message);
			email.addTo(toMessage);
			email.setCharset("GBK");
			email.send();
//		}catch (Exception e) {
//			
//			log.error("发送Eamil失败!!!");
//		}
	}
	
	public static void main(String[] args)  {
		
//		sendEmailMessage("123444", "415497731@qq.com");
		
//		String message = MD5Util.encodePassword(users.getUsername() + (Math.round(9)) + (Math.round(9)) + (Math.round(9)));
		
		System.out.println((int)(Math.random() * 10));
	}
	
}
